package com.turbo.boot.crawler.spider.worker;

import com.turbo.boot.crawler.dao.entity.CrawlerConfigEntity;
import com.xuxueli.crawler.loader.strategy.SeleniumPhantomjsPageLoader;

/**
 * 描述
 *
 * @author wuyn
 * @since 2024/4/17
 */
public abstract class BaseTurboJsCrawler<PageVo> extends BaseTurboCrawler<PageVo> {


    public  static final String driverPath = "/Users/wuyingnan/data/driver/phantomjs";

    @Override
    public boolean build() {
        CrawlerConfigEntity configEntity = crawlerConfigDal.selectByCrawlerRef(name());

        if (null == configEntity) {
            return false;
        }

        xxlCrawlerBuilder.setUrls(configEntity.getTargetUrls())
                .setAllowSpread(false)
                .setPageLoader(new SeleniumPhantomjsPageLoader(driverPath))
                .setThreadCount(configEntity.getThreadCounts())
                .setPageParser(getPageParser());
        return true;
    }

}
